﻿using System;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;


namespace FS_Config
{
    /// <summary>
    /// Reduces a numeric value to a simple value which 
    /// indicates if it is negative, zero, or positive.
    /// Returns -1 for a negative number, 0 for zero, 
    /// and +1 for a positive number.
    /// </summary>
    [ValueConversion(typeof(object), typeof(int))]
    public class NumberToPolarValueConverter : IValueConverter
    {
        public object Convert(
            object value, Type targetType,
            object parameter, CultureInfo culture)
        {
            double number = (double)System.Convert.ChangeType(value, typeof(double));


            if (number > 3)
                return 3;
            else if (number >= 2 && number <= 3)
                return 2;            
            else if (number == 1)
                return 1;
            
            return 0;
        }

        public object ConvertBack(
            object value, Type targetType,
            object parameter, CultureInfo culture)
        {
            throw new NotSupportedException("ConvertBack not supported");
        }
    }
}
